package com.example.linuxweb.service;

import com.example.linuxweb.model.TerminalSession;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

@Service
public class FileSystemService {
    private Map<String, TerminalSession> sessions;

    @PostConstruct
    public void init() {
        sessions = new HashMap<>();
    }

    public TerminalSession createNewSession() {
        String sessionId = UUID.randomUUID().toString();
        TerminalSession session = new TerminalSession();
        sessions.put(sessionId, session);
        return session;
    }

    public TerminalSession getSession(String sessionId) {
        return sessions.get(sessionId);
    }

    public Map<String, TerminalSession> getSessions() {
        return sessions;
    }

}